#include"programnode.h"
#include"variablenode.h"
#include"integernode.h"
#include"operatornode.h"
#include"lambdanode.h"
#include "parser.h"
#include <iostream>
#include <map>

using namespace std;


int main() {
	/*VariableNode fact("fact");
	VariableNode n("n");
	IntegerNode zero(0);
	IntegerNode one(1);
	IntegerNode arb(10);
	OperatorNode n_1(_MINUS, n.copy(), one.copy());
	ApplicationNode f_n_1(fact.copy(), n_1.copy());
	OperatorNode n_f_n_1(_MULT, n.copy(), f_n_1.copy());
	OperatorNode n_gt_0(_GT, n.copy(), zero.copy());
	ChoiceNode if_(n_gt_0.copy(), n_f_n_1.copy(), one.copy());
	FunctionNode lambda_(n, if_.copy());
	ProgramNode p(fact, &lambda_);
	ApplicationNode eval_(fact.copy(), arb.copy());
	cout << p.toString();
	cout << eval_.toString() << endl;
	ExpressionNode * res = eval_.eval(p);
	cout << res -> toString() << endl;
	delete res;*/
	LambdaParser parser;
	pair<ProgramNode*,ExpressionNode*> p = parser.parse(cin);
	ExpressionNode * res = p.second->eval(*p.first);
	cout << res -> toString() << endl;

	return 0;
}
